//
//  HeadImgViewController.m
//  WBBaseProject
//
//  Created by xiaozhi on 2018/3/28.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "HeadImgViewController.h"
#import "ZZYPhotoHelper.h"

@interface HeadImgViewController ()

@property(nonatomic, strong)UIImageView *imgV;

@end

@implementation HeadImgViewController

- (UIImageView *)imgV
{
    if (!_imgV) {
        _imgV = [[UIImageView alloc]init];
    }
    return _imgV;
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBg"] forBarMetrics:0];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[Factory createImageWithColor:WB_RGBColor(40, 40, 40)] forBarMetrics:0];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"个人头像";
    
    
    
    self.view.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.imgV];
    self.imgV.backgroundColor = [UIColor lightGrayColor];
    [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(50);
        make.left.equalTo(0);
        make.size.equalTo(CGSizeMake(kScreenWidth, kScreenWidth));
    }];
    
    [self addNavBtn];
    
    [self wb_starYingHuaCoreAnimation];
    //[self wb_showBallLoadingView:YES];
    //[self.navigationController.navigationBar setBarTintColor:[UIColor darkGrayColor]];
}

- (void)addNavBtn{
    
    UIButton *right = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    right.titleLabel.font = [UIFont boldSystemFontOfSize:30];
    [right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [right setTitle:@"..." forState:UIControlStateNormal];
    right.contentEdgeInsets = UIEdgeInsetsMake(-20, 0, 0, 0);
    [right addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:right];
    self.navigationItem.rightBarButtonItem = item;
}

- (void)click
{
    WB_WeakSelf(self)
    [[ZZYPhotoHelper shareHelper] showImageViewSelcteWithResultBlock:^(id data) {
        
        weakself.imgV.image = (UIImage *)data;
        //DebugLog(@"上传图片--%@---",[[NSUserDefaults standardUserDefaults] objectForKey:Token]);
        
//        [ZWCommonHttp dataRequestWithHeadUploadWithHeadImage:UIImageJPEGRepresentation(data, 0.3) success:^(id responseObj) {
//            ;
//            if (SUCCESS) {
//                weakself.headIconIV.image = (UIImage *)data;
//                DebugLog(@"上传图片--%@---%@",responseObj,[[NSUserDefaults standardUserDefaults] objectForKey:Token]);
//                [[NSNotificationCenter defaultCenter]postNotificationName:@"changUI" object:nil];
//            }
//        } failure:^(NSError *error) {
//        }];
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
